package com.luoying.itew.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.luoying.itew.fragment.ChartsFragment;
import com.luoying.itew.fragment.ChartsWeatherFragment;
import com.luoying.itew.fragment.CollectorFragment;
import com.luoying.itew.fragment.DetailsFragment;
import com.luoying.itew.fragment.InspectLogFragment;


/**
 * Created by Administrator on 2017/5/22.
 */
public class NewInformationAdapter extends FragmentStatePagerAdapter {
    final int FRAGMENT_DETAILS= 0;
    final int FRAGMENT_CHARTS = 1;
    final int FRAGMENT_WEATHER = 2;
    final int FRAGMENT_COLLECTOR = 3;
     final int FRAGMENT_INSPECT_LOG = 4;
    private String[] dataList;

    public NewInformationAdapter(FragmentManager fm, String[] dataList) {
        super(fm,BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.dataList = dataList;
    }



    @Override
    public CharSequence getPageTitle(int position) {
        return dataList[position];
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment;
        switch (position) {
            case FRAGMENT_DETAILS://监测点详情
            default:
                fragment = new DetailsFragment();
                break;
            case FRAGMENT_CHARTS:   //统计图表
                fragment = new ChartsFragment();
                break;
            case FRAGMENT_COLLECTOR:    //采集器
                fragment = new CollectorFragment();
                break;
            case FRAGMENT_INSPECT_LOG:  //巡查日志
                fragment = new InspectLogFragment();
                break;
            case FRAGMENT_WEATHER:  //天气图表
                fragment = new ChartsWeatherFragment();
                break;
        }
        return  fragment;
    }

    @Override
    public int getCount() {
        return dataList.length;
    }
}
